<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">项目名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">归属组织</label>
        <div class="layui-input-inline">
            <input type="text" name="title" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <button class="layui-btn">新增组织</button>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">路径</label>
        <div class="layui-input-block">
            <input type="text" name="title" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目说明</label>
        <div class="layui-input-block">
            <textarea id="projectDesc" style="display: none;"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类别</label>
        <div class="layui-input-block">
            <select name="city">
                <option value="0">公开</option>
                <option value="1">私有</option>
                <option value="2">个人</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">添加标签</label>
        <div class="layui-input-inline">
            <input type="text" name="title" autocomplete="off" class="layui-input" id = "tagValue">
        </div>
        <div class="layui-input-inline">
            <a class="layui-btn" id="addTag">添加</a>
        </div>
        <!-- -->
        <div class="layui-input-inline" style="border:1 solid black;" >
            <label class="layui-form-label" style="width:500px;" id = "tagContext">尚未添加标签</label>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">创建</button>
            <button type="reset" class="layui-btn layui-btn-primary">取消</button>
        </div>
    </div>

</form>

<script>

    layui.use(['form', 'table', 'util', 'config', 'admin', 'formSelects', 'layedit'], function () {
        var layedit = layui.layedit;
        var index = layedit.build('projectDesc', {color:'red'}); //建立编辑器
        // layedit.

        var body = "<b>输入项目说明</b>";
        layedit.setContent(index,body);

    });

    /* */
    $(document).on('click', '#addTag', function() {
        if ($(".tagAddBtn").length >= 5) {
            //alert($(".tagAddBtn").eq(0).attr("value"));
            layer.msg('标签最多只能输入5个');
            $("#tagValue").val("");
            return;
        }

        var tagValue = $("#tagValue").val();
        if (tagValue != '' && tagValue != null) {
            
            if ($("#tagContext").html() == "尚未添加标签" ) {
                $("#tagContext").html("");
            }
            

            var tagBuggonHTML = "<button class='layui-btn tagAddBtn' style='cursor:default' value='" 
            + tagValue +  "' >" + tagValue 
            + "&nbsp;&nbsp;<a class='removeTag' style='cursor:pointer'><i class='layui-icon layui-icon-close' style='font-size: 14px; color: black'></i></a></button>";

            $("#tagContext").append(tagBuggonHTML);
            $("#tagValue").val("");

            $(".tagAddBtn").click(function(){
                return false;
            });

            $(".removeTag").click(function(){
                $(this).parent().remove();
            });
        } else {
            layer.msg('请输入标签');
        }
    });
 
</script>



<script>
    //alert(window.location);
</script>